package com.ostraffel.recallvocabularybackend.service.sqlutilesinterface;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.ostraffel.recallvocabularybackend.DTO.OriginWord;
import com.ostraffel.recallvocabularybackend.DTO.Word;

@Mapper
public interface SqlUtilsInterface {
    @Select("SELECT word, translate FROM recall_word.senior")
    List<OriginWord> GetWordsFromOrigin();

    @Select("SELECT * FROM recall_word.highschool_words")
    List<Word> GetWordsFromPrototypeTable();

    @Insert("INSERT INTO recall_word.highschool_words (id, spell, ipa, explication, proficiency, lastDate, userId) VALUES (#{id}, #{spell}, #{ipa}, #{explication}, #{proficiency}, #{lastDate}, #{userId})")
    void AddWordsToTable(@Param("id") String id, @Param("spell") String spell, @Param("ipa") String ipa, @Param("explication") String explication, @Param("proficiency") int proficiency, @Param("lastDate") Date lastDate, @Param("userId") String userId);

    @Insert("INSERT INTO recall_word.highschool_words_production (id, spell, ipa, explication, proficiency, lastDate, userId) VALUES (#{id}, #{spell}, #{ipa}, #{explication}, #{proficiency}, #{lastDate}, #{userId})")
    void CopyWordsToProductTable(@Param("id") String id, @Param("spell") String spell, @Param("ipa") String ipa, @Param("explication") String explication, @Param("proficiency") int proficiency, @Param("lastDate") Date lastDate, @Param("userId") String userId);
    /**
     * 删除userId对应所有数据
     * @param userId
     */
    @Delete("DELETE FROM recall_word.highschool_words_production WHERE userId = #{userId}")
    void ClearProductionTableById(@Param("userId") String userId);
}
